#pragma once

#include "ftp/Types.h"
#include "ftp/ServerPI.h"

#include <boost/ptr_container/ptr_vector.hpp>

namespace ftp
{

class Server
{
public:
	Server(int port, FileSystem* fileSystem);

	void run();

private:
	void acceptServerPI();
	void onAcceptServerPiSocket(SocketSPtr socket, const boost::system::error_code& error);
	void readDataForServerPI(tcp::socket* socket, ServerPI* serverPI);
	void onDataReadForServerPi(tcp::socket* socket, ServerPI* serverPi, boost::shared_ptr<std::vector<char> > vector, const boost::system::error_code& error, size_t bytesRead);

private:
	ba::io_service m_ioService;
	std::auto_ptr<tcp::acceptor> m_acceptor;

	boost::ptr_vector<ServerPI> m_serverPIs; 

	FileSystem* m_fileSystem;
};

} //ftp
